GBML manual / Camera

camera_dead_zone

A box in the middle of the view, width by height pixels, inside which the followed target can move without the camera moving. The camera moves only to keep the target inside the box. 0 and 0 (the default) is no box.

Sega Genesis: not built yet

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

camera_dead_zone(width, height)

Arguments

NameType
widthreal
heightreal

Returns

Nothing.

Description

Gives the followed camera a dead zone: a box in the middle of the screen, width pixels wide and height pixels tall. While the thing the camera follows stays inside the box, the camera does not move at all. When it walks out through an edge, the camera moves just enough to keep it on that edge of the box.

It is what stops a small step from shaking the whole picture. A platformer player can hop on the spot without the world bobbing, and the camera only starts to scroll once the player has really gone somewhere.

0 and 0 is no box, which is how the camera has always been: it follows the exact spot. The setting stays until you change it, whoever is followed and whichever room you are in, like camera_follow_ease. A number below 0 counts as 0.

The box is centered on the camera, so it works together with camera_offset and camera_look_ahead: they move the spot the camera wants to be on, and the box decides when the camera bothers to go there. When a room starts and the camera jumps to its target (see camera_snap), it goes straight to the middle: the box only holds the camera back while it is following.

Room Properties and World Properties have the same setting in their Camera section. What you set there is applied when the room starts, before any of your code runs, so a call to this function always has the last word.

Example

camera_dead_zone(64, 32);

A box 64 pixels wide and 32 tall. The followed object can wander 32 pixels left or right and 16 up or down of the middle of the screen before the camera moves.

On the GBA

A project-wide setting like camera_follow_ease: it holds across targets, rooms and cutscenes until changed. Room Properties and World Properties have the same setting in their Camera section; a call in code always overrides what the panel set.

See also: The cameracamera_followcamera_follow_easecamera_look_aheadcamera_offset